package com.ess.project.examine.record.compute;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 三项：引体向上, 俯卧撑, 曲臂悬垂
 * 1.单杠引体向上超出100分后每递增1次增加1分；单杠屈臂悬垂超出100分后每递增5秒增加1分；俯卧撑超出100分后每递增2次增加1分。
 * 2.俯卧撑考核时间为2分钟。
 * @Date: Created in 7:45 下午 2021/3/7
 * @Author: daihui
 * @Modified By:
 */
public class ThreeTermExamineStrategy implements BaseExamine<Integer> {

    private static final Map<Integer, Integer[]> MAN_DIC_DATA = new HashMap<>(13);
    private static final Map<Integer, Integer[]> WOMAN_DIC_DATA = new HashMap<>(13);

    static {
        initDicData();
    }

    private static void initDicData(){
        Integer[] manGradeArray24 = {10, 11, 11, 12, 12, 14, 14, 15, 15, 18, 18, 21, 21, 24, 24, 27, 27, 30, 30, MAX_NUMBER};
        Integer[] manGradeArray2527 = {9, 10, 10, 11, 11, 13, 13, 14, 14, 16, 16, 19, 19, 22, 22, 25, 25, 28, 28, MAX_NUMBER};
        Integer[] manGradeArray2830 = {8, 9, 9, 10, 10, 11, 11, 12, 12, 14, 14, 17, 17, 20, 20, 23, 23, 26, 26, MAX_NUMBER};
        Integer[] manGradeArray3133 = {7, 8, 8, 9, 9, 10, 10, 11, 11, 13, 13, 15, 15, 17, 17, 20, 20, 23, 23, MAX_NUMBER};
        Integer[] manGradeArray3436 = {6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 14, 14, 17, 17, 20, 20, MAX_NUMBER};
        Integer[] manGradeArray3739 = {5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 13, 13, 15, 15, 17, 17, MAX_NUMBER};
        Integer[] manGradeArray4042 = {27, 28, 28, 29, 29, 34, 34, 39, 39, 45, 45, 51, 51, 57, 57, 65, 65, 73, 73, MAX_NUMBER};
        Integer[] manGradeArray4345 = {26, 27, 27, 28, 28, 31, 31, 37, 37, 43, 43, 49, 49, 55, 55, 62, 62, 69, 69, MAX_NUMBER};
        Integer[] manGradeArray4648 = {23, 24, 24, 25, 25, 30, 30, 36, 36, 42, 42, 48, 48, 54, 54, 61, 61, 68, 68, MAX_NUMBER};
        Integer[] manGradeArray4951 = {21, 22, 22, 23, 23, 28, 28, 34, 34, 40, 40, 46, 46, 52, 52, 59, 59, 66, 66, MAX_NUMBER};
        Integer[] manGradeArray5254 = {18, 19, 19, 20, 20, 26, 26, 32, 32, 38, 38, 44, 44, 51, 51, 58, 58, 65, 65, MAX_NUMBER};
        Integer[] manGradeArray5557 = {16, 17, 17, 18, 18, 24, 24, 30, 30, 36, 36, 42, 42, 48, 48, 55, 55, 62, 62, MAX_NUMBER};
        Integer[] manGradeArray5860 = {10, 11, 11, 12, 12, 15, 15, 20, 20, 25, 25, 29, 29, 34, 34, 39, 39, 44, 44, MAX_NUMBER};
        MAN_DIC_DATA.put(DATA_KEY_24, manGradeArray24);
        MAN_DIC_DATA.put(DATA_KEY_2527, manGradeArray2527);
        MAN_DIC_DATA.put(DATA_KEY_2830, manGradeArray2830);
        MAN_DIC_DATA.put(DATA_KEY_3133, manGradeArray3133);
        MAN_DIC_DATA.put(DATA_KEY_3436, manGradeArray3436);
        MAN_DIC_DATA.put(DATA_KEY_3739, manGradeArray3739);
        MAN_DIC_DATA.put(DATA_KEY_4042, manGradeArray4042);
        MAN_DIC_DATA.put(DATA_KEY_4345, manGradeArray4345);
        MAN_DIC_DATA.put(DATA_KEY_4648, manGradeArray4648);
        MAN_DIC_DATA.put(DATA_KEY_4951, manGradeArray4951);
        MAN_DIC_DATA.put(DATA_KEY_5254, manGradeArray5254);
        MAN_DIC_DATA.put(DATA_KEY_5557, manGradeArray5557);
        MAN_DIC_DATA.put(DATA_KEY_5860, manGradeArray5860);
        Integer[] womanGradeArray24 = {30, 36, 36, 42, 42, 46, 46, 50, 50, 54, 54, 58, 58, 62, 62, 66, 66, 70, 70, MAX_NUMBER};
        Integer[] womanGradeArray2527 = {29, 35, 35, 39, 39, 43, 43, 47, 47, 51, 51, 55, 55, 59, 59, 62, 62, 65, 65, MAX_NUMBER};
        Integer[] womanGradeArray2830 = {27, 33, 33, 37, 37, 41, 41, 45, 45, 49, 49, 53, 53, 57, 57, 60, 60, 63, 63, MAX_NUMBER};
        Integer[] womanGradeArray3133 = {24, 30, 30, 34, 34, 38, 38, 42, 42, 46, 46, 50, 50, 54, 54, 57, 57, 60, 60, MAX_NUMBER};
        Integer[] womanGradeArray3436 = {21, 27, 27, 31, 31, 35, 35, 39, 39, 43, 43, 47, 47, 51, 51, 54, 54, 57, 57, MAX_NUMBER};
        Integer[] womanGradeArray3739 = {18, 24, 24, 28, 28, 32, 32, 36, 36, 40, 40, 44, 44, 48, 48, 51, 51, 54, 54, MAX_NUMBER};
        Integer[] womanGradeArray4042 = {13, 14, 14, 15, 15, 16, 16, 17, 17, 19, 19, 21, 21, 24, 24, 27, 27, 30, 30, MAX_NUMBER};
        Integer[] womanGradeArray4345 = {11, 12, 12, 13, 13, 15, 15, 16, 16, 17, 17, 19, 19, 21, 21, 24, 24, 27, 27, MAX_NUMBER};
        Integer[] womanGradeArray4648 = {11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 19, 19, 21, 21, 24, 24, MAX_NUMBER};
        Integer[] womanGradeArray4951 = {9, 10, 10, 11, 11, 12, 12, 14, 14, 15, 15, 16, 16, 17, 17, 19, 19, 21, 21, MAX_NUMBER};
        Integer[] womanGradeArray5254 = {8, 9, 9, 10, 10, 11, 11, 12, 12, 14, 14, 15, 15, 16, 16, 17, 17, 19, 19, MAX_NUMBER};
        Integer[] womanGradeArray5557 = {7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 14, 14, 15, 15, 16, 16, 17, 17, MAX_NUMBER};
        Integer[] womanGradeArray5860 = {3, 4, 4, 5, 5, 7, 7, 10, 10, 11, 11, 12, 12, 14, 14, 15, 15, 16, 16, MAX_NUMBER};
        WOMAN_DIC_DATA.put(DATA_KEY_24, womanGradeArray24);
        WOMAN_DIC_DATA.put(DATA_KEY_2527, womanGradeArray2527);
        WOMAN_DIC_DATA.put(DATA_KEY_2830, womanGradeArray2830);
        WOMAN_DIC_DATA.put(DATA_KEY_3133, womanGradeArray3133);
        WOMAN_DIC_DATA.put(DATA_KEY_3436, womanGradeArray3436);
        WOMAN_DIC_DATA.put(DATA_KEY_3739, womanGradeArray3739);
        WOMAN_DIC_DATA.put(DATA_KEY_4042, womanGradeArray4042);
        WOMAN_DIC_DATA.put(DATA_KEY_4345, womanGradeArray4345);
        WOMAN_DIC_DATA.put(DATA_KEY_4648, womanGradeArray4648);
        WOMAN_DIC_DATA.put(DATA_KEY_4951, womanGradeArray4951);
        WOMAN_DIC_DATA.put(DATA_KEY_5254, womanGradeArray5254);
        WOMAN_DIC_DATA.put(DATA_KEY_5557, womanGradeArray5557);
        WOMAN_DIC_DATA.put(DATA_KEY_5860, womanGradeArray5860);
    }
    @Override
    public Integer compute(Object args, String gender, Integer... grade) {
        Integer[] arr;
        int age = (int) args;
        String examinationItem;
        if (age > 39) {
            if (MAN.equals(gender)) {
                arr = MAN_DIC_DATA.get(BaseExamine.dicKey(age));
            } else {
                arr = WOMAN_DIC_DATA.get(BaseExamine.dicKey(age));
            }
            // 俯卧撑
            examinationItem = EXAMINATION_ITEM_PUSH_UP;
        } else {
            if (MAN.equals(gender)) {
                // 引体向上
                examinationItem = EXAMINATION_ITEM_PULL_UP;
                arr = MAN_DIC_DATA.get(BaseExamine.dicKey(age));
            } else {
                // 曲臂悬垂
                examinationItem = EXAMINATION_ITEM_FLEX_ARM_HANG;
                arr = WOMAN_DIC_DATA.get(BaseExamine.dicKey(age));
            }
        }
        return BaseExamine.getScore(grade[0], examinationItem, arr);
    }
}
